//package com.zjuee.service.company.service;
//
//
//import javax.crypto.Cipher;
//import javax.crypto.spec.IvParameterSpec;
//import javax.crypto.spec.SecretKeySpec;
//import java.security.Security;
//import java.util.Base64;
//
//public class EncryptUtil {
//
//	static {
//		Security.addProvider(new BouncyCastleProvider());
//	}
//
//	public static String encrypt(String key, String iv, String data) {
//		try {
//			Cipher cipher = Cipher.getInstance("AES/CBC/ZeroBytePadding", "BC");
//			byte[] dataBytes = data.getBytes("UTF-8");
//
//			SecretKeySpec keyspec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
//			IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes("UTF-8"));
//
//			cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
//			byte[] encrypted = cipher.doFinal(dataBytes);
//
//			return Base64.getEncoder().encodeToString(encrypted);
//		} catch (Exception e) {
//			e.printStackTrace();
//			return null;
//		}
//	}
//
//	public static String decrypt(String key, String iv, String data) throws Exception {
//		try {
//			byte[] encrypted = Base64.getDecoder().decode(data);
//
//			Cipher cipher = Cipher.getInstance("AES/CBC/ZeroBytePadding", "BC");
//			SecretKeySpec keyspec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
//			IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes("UTF-8"));
//
//			cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
//
//			byte[] original = cipher.doFinal(encrypted);
//			String originalString = new String(original, "UTF-8");
//			return originalString;
//		} catch (Exception e) {
//			e.printStackTrace();
//			return null;
//		}
//	}
//}